package org.example.infrastructure.persistence.orm;


import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.example.domain.model.entity.url.UrlShortener;
import org.example.domain.model.entity.url.req.UrlShortenerSelectReq;
import org.example.domain.model.entity.url.resp.QueryGroupByCountResp;
import org.example.domain.model.entity.url.vo.UrlShortenerUpdateVo;
import org.example.domain.model.entity.url.vo.UrlShortenerVo;

import java.util.List;
import java.util.Optional;

@Mapper
public interface UrlShortenerMapper extends BaseMapper<UrlShortener> {


    Optional<UrlShortenerVo> selectUrlShortener(@Param(value = "fullShortUrl") String fullShortUrl);

    void updateUrlShortEnerByFullShortUrl(@Param(value = "vo") UrlShortenerUpdateVo urlShortenerUpdateVo,
                                          @Param(value = "oldFullShortUrl") String oldFullShortUrl,
                                          @Param(value = "gid") String gid);

    List<UrlShortener> selectByPage(UrlShortenerSelectReq urlShortenerSelectReq);

    List<QueryGroupByCountResp>  queryGroupByCount(@Param(value = "gidList") List<String> gidList);

    void incrementStats(@Param(value = "gid") String gid,
                        @Param(value = "fullShortUrl") String fullShortUrl,
                        @Param(value = "totalPv") Integer totalPv,
                        @Param(value = "totalUv") Integer totalUv,
                        @Param(value = "totalUip") Integer totalUip);


}
